#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    char f[n + 1];
    for (int i = 2; i <= n; i++)
        f[i] = 1;

    for (int i = 2; i <= n; i++)
        if (f[i])
            for (int p = 2; p * i <= n; p++)
                f[p * i] = 0;

    int sum = 0;
    for (int i = 3; i + 2 <= n; i++)
        if (f[i] && (i + 2 <= n) && f[i + 2])
        {
            sum++;
            f[i] = 2;
        }

    printf("%d\n", sum);
    for (int i = 3; i + 2 <= n; i++)
        if (f[i] == 2)
            printf("2 %d\n", i);

    return 0;
}
